package util;

import com.fasterxml.jackson.databind.ObjectMapper;
import model.assessment.QuestionDB;
import model.assessment.TemplateDB;
import model.hospital.BuildingDB;
import model.hospital.PatientDB;
import model.user.StaffDB;

import java.io.File;

public class DataStore {
    public static void store(){
        questionStore();
        templateStore();
        buildingStore();
        patientStore();
        staffStore();
    }

    public static void questionStore(){
        ObjectMapper om = new ObjectMapper();
        File f = new File("Question_DB.json");
        try {
            om.writeValue(f, QuestionDB.getInstance().getQuestions());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public static void templateStore(){
        ObjectMapper om = new ObjectMapper();
        File f = new File("Template_DB.json");
        try {
            om.writeValue(f, TemplateDB.getInstance().getTemplates());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public static void buildingStore(){
        ObjectMapper om = new ObjectMapper();
        File f = new File("Building_DB.json");
        try {
            om.writeValue(f, BuildingDB.getInstance().getBuildings());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public static void patientStore(){
        ObjectMapper om = new ObjectMapper();
        File f = new File("Patient_DB.json");
        try {
            om.writeValue(f, PatientDB.getInstance().getPatients());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void staffStore(){
        ObjectMapper om = new ObjectMapper();
        File f = new File("Staff_DB.json");
        try {
            om.writeValue(f, StaffDB.getInstance().getStaffs());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
